package com.maoyan.quickdevelop.controller;

import com.maoyan.quickdevelop.common.core.AjaxResult;
import com.maoyan.quickdevelop.common.utils.UploadFile;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 猫颜
 * @date 2021/6/2 19:55
 * 文件上传工具类(上传时参数key为file)！！！！
 */
@RestController
@RequestMapping("/upload/")
public class UploadController {

    /**
     * 上传图片
     */
    @PostMapping("image")
    @ApiOperation(value = "图片上传")
    public AjaxResult image(MultipartFile file) {
        String upload = null;
        try {
            upload = UploadFile.upload(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return AjaxResult.success(upload);
    }

}
